<template>
  <div>
    <el-form>
      <el-form-item label="链接：" label-width="80px">
        <el-input v-model="menudata.path" size="small" placeholder="请输入内容"></el-input>
        <!--还提供了 medium、small 和 mini 三种尺寸。-->
      </el-form-item>
      <el-form-item label="名字：" label-width="80px">
        <el-input v-model="menudata.title" size="small" placeholder="请输入内容"></el-input>
      </el-form-item>

      <el-button @click="updateMenu()">确定</el-button>
      <el-button @click='diaclose()'>关闭</el-button>
    </el-form>
  </div>
</template>

<script>
import qs from "qs";
export default {
  name: "updateMenu",
  inject: ['dialog_close', 'reload'],
  props: ['selectedId'],
  data() {
    return {
      menudata: {},
    }
  },
  /**
   * 提前执行，将传过来的id进行查询得到信息
   */
  created() {
    let that = this;
    this.axios.post('http://localhost:8080/select_menuid', qs.stringify({"id": this.selectedId})).then(function (res) {
      that.menudata = res.data
    })
  },

  methods: {
    /**
     * 关闭对话框
     */
    diaclose() {
      var that = this;
      that.dialog_close();

    },

    /**
     * 修改菜单名字和链接
     */
    updateMenu() {
      var menu = this.menudata
      var that = this;

      console.log(menu)
      this.axios.post('http://localhost:8080/update_menu_information', menu).then(function (res) {

        if (res.data == "1") {
          that.$message({message: '成功', type: 'success'})
          that.reload();
        }
      })

    }

  }
}
</script>

<style scoped>

</style>
